package com.zkc.blog.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zkc.blog.mapper.BlogcateMapper;
import com.zkc.blog.pojo.Blogcate;
import com.zkc.blog.pojo.BlogcateExample;
import com.zkc.blog.service.BlogCateService;

@Service
public class BlogCateServiceImpl implements BlogCateService {

	@Autowired
	private BlogcateMapper cateMapper;
	
	@Override
	public List<Blogcate> getBlogCateList(String searchKey) {
		searchKey="%"+searchKey+"%";
		BlogcateExample ex=new BlogcateExample();
		ex.createCriteria().andCatenameLike(searchKey);
		List<Blogcate> list=cateMapper.selectByExample(ex);
		return list;
	}

	@Override
	public Blogcate getBlogCateById(Integer id) {
		Blogcate cate=cateMapper.selectByPrimaryKey(id);
		return cate;
	}
	
	@Override
	public void insertBlogCate(Blogcate cate) {
		// TODO Auto-generated method stub
		cateMapper.insert(cate);
	}

	@Override
	public void DeleteBlogCate(List<Integer> cateids) {
		// TODO Auto-generated method stub
		BlogcateExample ex=new BlogcateExample();
		ex.createCriteria().andCateidIn(cateids);
		cateMapper.deleteByExample(ex);
	}

	@Override
	public void UpdateBlogCate(Blogcate cate) {
		// TODO Auto-generated method stub
		cateMapper.updateByPrimaryKey(cate);
	}

}
